package com.sanyue.springboot.controller;

import com.sanyue.springboot.bean.Monster;
import com.sanyue.springboot.service.MonsterService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: Guan
 **/
@Controller
public class MonsterController {
    @Resource
    private MonsterService monsterService;

    @ResponseBody
    @GetMapping("/findMonsterById")
    public Monster getMonsterById(@RequestParam("id") Integer id){
        Monster byId = monsterService.getById(id);
        return byId;
    }

    @ResponseBody
    @GetMapping("/findAllMonsters")
    public List<Monster> listMonster(){
        List<Monster> list = monsterService.list();
        return list;
    }
}
